  /**
   * 准备创建代币交易 - 简化版，只用一笔交易
   */
  async prepareCreateTransactionSimple(dto: PrepareXLayerCreateDto) {
    if (!process.env.XLAYER_RPC_URL) {
      throw new Error('XLAYER_RPC_URL environment variable is required');
    }
    if (!process.env.XLAYER_LAUNCHPAD_ADDRESS) {
      throw new Error('XLAYER_LAUNCHPAD_ADDRESS environment variable is required');
    }
    const provider = new ethers.JsonRpcProvider(process.env.XLAYER_RPC_URL);
    const contract = new ethers.Contract(
      process.env.XLAYER_LAUNCHPAD_ADDRESS,
      [
        'function createTokenLaunch(string memory _name, string memory _symbol, string memory _description, string memory _website, string memory _telegram, string memory _twitter, uint256 _targetAmount) external payable'
      ],
      provider
    );

    const targetAmountWei = ethers.parseEther(dto.targetAmount.toString());
    
    // 简化：只发送0.01 OKB给合约，平台收费暂时取消
    const contractFeeWei = ethers.parseEther('0.01');

    const txData = contract.interface.encodeFunctionData('createTokenLaunch', [
      dto.name,
      dto.symbol,
      dto.description,
      dto.website || '',
      dto.telegram || '',
      dto.twitter || '',
      targetAmountWei
    ]);

    // 获取gas价格
    const feeData = await provider.getFeeData();
    const gasPriceWei = feeData.gasPrice || ethers.parseUnits('1', 'gwei');
    
    // 估算gas
    let gasLimit = 500000n;
    try {
      const gasEstimate = await provider.estimateGas({
        to: process.env.XLAYER_LAUNCHPAD_ADDRESS,
        value: contractFeeWei,
        data: txData,
        from: dto.creatorAddress
      });
      gasLimit = gasEstimate * 120n / 100n; // 20% buffer
    } catch (error) {
      console.log('Gas estimation failed, using default:', error.message);
    }

    const totalGasFee = gasPriceWei * gasLimit;
    const totalCostWei = contractFeeWei + totalGasFee;

    return {
      success: true,
      transaction: {
        to: process.env.XLAYER_LAUNCHPAD_ADDRESS,
        value: contractFeeWei.toString(),
        data: txData,
        gasLimit: gasLimit.toString(),
        gasPrice: gasPriceWei.toString(),
        description: 'Token creation transaction'
      },
      estimate: {
        name: dto.name,
        symbol: dto.symbol,
        targetAmount: dto.targetAmount,
        creationFee: '0.01',
        gasFee: ethers.formatEther(totalGasFee),
        totalCost: ethers.formatEther(totalCostWei),
        contractFee: '0.01',
        platformFee: '0.00'
      }
    };
  }
